<?php
/**
 * Created by IntelliJ IDEA.
 * User: Rookiejin<mrjnamei@gmail.com>
 * Date: 2018/3/12
 * Time: 12:01
 */

namespace App\Http\Middleware;


use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Session;
use Ramsey\Uuid\Uuid;

class GenerateUniqueRediskey
{

    public function handle(Request $request, \Closure $next)
    {
        if(!$request->session()->has("uuid")){
            $uuid = Uuid::uuid4() ;
            /* @var $response Response */
            $request->session()->put("uuid", $uuid);
        }

        return $next($request);
    }
}